package com.baizhi.wwx.controller;

import com.baizhi.wwx.dao.UserMapper;
import com.baizhi.wwx.entity.User;
import com.baizhi.wwx.service.UserService;
import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

@Controller
@RequestMapping("user")
@CrossOrigin
public class UserController {
    @Autowired
    private UserService userService;
    @RequestMapping("queryAllPage")
    @ResponseBody
    public Map<String, Object> queryAllPage(int page, int pageSize){
        return userService.queryAllPage(page,pageSize);
    }
    @RequestMapping("update")
    @ResponseBody
    public Map<String,Object>update(@RequestBody User user){
        return userService.update(user.getId(),user.getStatus());
    }
    @RequestMapping("delete")
    @ResponseBody
    public Map<String,Object>delete(@RequestBody User user){
        return userService.delete(user.getId());
    }
}
